
import os
import jinja2 
import webapp2

JINJA_ENVIRONMENT = jinja2.Environment(
    loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
    extensions=['jinja2.ext.autoescape'],
    autoescape=True)

class OnePage(webapp2.RequestHandler):
  def loadEntries(self):
    self.entries = []


  def get(self):
    self.loadEntries()
    templateValues = {
    }
    template = JINJA_ENVIRONMENT.get_template('template/onepage.html')
    self.response.write(template.render(templateValues))


class PostPage(webapp2.RequestHandler):
  template = JINJA_ENVIRONMENT.get_template('template/postpage.html')
  debugOutput = True

  def get(self):
    templateValues = {
      'message': 'This page don\'t exist',
    }
    self.response.write(self.template.render(templateValues))

  def post(self):
    templateValues = {
      'message': 'Your message had recorded',
    }
    email = self.request.get('email')
    targetEmail = self.request.get('targetEmail')
    content = self.request.get('content')
    credential = self.request.get('credential')
    templateValues = {
      'message': 'Your message had recorded',
      'email' : email,
      'targetEmail' : targetEmail,
      'content' : content,
      'credential' : credential,
      'debugOutput' : self.debugOutput,
    }
    print templateValues
    self.response.write(self.template.render(templateValues))

